#include <in_sock.h>

#include <e32std.h>
#include <e32err.h>

#include <arpa\inet.h>
#include <netinet\in.h>

extern "C" {
void __assert(const char *fl, int line, const char *err) {
	(void)fl; (void)line, (void)err;
	User::Invariant();
}

int inet_aton (const char* str, struct in_addr* inaddr) {
	if (User::StringLength((TUint8*)str) > 20) {
		return 0;
	}
	TInetAddr addr;
	TBuf<20> buf;
	buf.Copy(TPtrC8((const unsigned char *)str));
	int err = addr.Input(buf);
	if (err == KErrNone) {
		inaddr->s_addr = ByteOrder::Swap32(addr.Address());
		return 1;
	}
	return 0;
}

int *__errno(void) {
	return const_cast<int*>(&KErrGeneral);
}

size_t strlen(const char* st) {
	return User::StringLength((const TUint8*)st);
}
}
